<?php

namespace Renshan\DetectorBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * ReqGroup
 *
 * @ORM\Table(name="req_group")
 * @ORM\Entity(repositoryClass="Renshan\DetectorBundle\Repository\ReqGroupRepository")
 */
class ReqGroup
{
    /**
     * @var int
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var string
     *
     * @ORM\Column(name="title", type="string", options={"comment": "分组标题"})
     */
    private $title;

    /**
     * @var int
     *
     * @ORM\Column(name="times", type="integer", options={"comment": "完成次数"})
     */
    private $times;

    /**
     * @var int
     *
     * @ORM\Column(name="timing", type="integer", options={"comment": "定时"})
     */
    private $timing;

    /**
     * @var Renshan\DetectorBundle\Entity\User
     *
     * @ORM\ManyToOne(targetEntity="Renshan\UserBundle\Entity\User", inversedBy="req_groups")
     */
    private $user;

    /**
     * @var array
     *
     * @ORM\ManyToMany(targetEntity="Target", mappedBy="req_group")
     */
    private $targets;

    /**
     * @var array
     *
     * @ORM\OneToMany(targetEntity="Result", mappedBy="req_group")
     */
    private $results;

    /**
     * Constructor
     */
    public function __construct()
    {
        $this->targets = new \Doctrine\Common\Collections\ArrayCollection();
        $this->results = new \Doctrine\Common\Collections\ArrayCollection();
    }

    /**
     * Get id
     *
     * @return integer
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set title
     *
     * @param string $title
     *
     * @return ReqGroup
     */
    public function setTitle($title)
    {
        $this->title = $title;

        return $this;
    }

    /**
     * Get title
     *
     * @return string
     */
    public function getTitle()
    {
        return $this->title;
    }

    /**
     * Set times
     *
     * @param integer $times
     *
     * @return ReqGroup
     */
    public function setTimes($times)
    {
        $this->times = $times;

        return $this;
    }

    /**
     * Get times
     *
     * @return integer
     */
    public function getTimes()
    {
        return $this->times;
    }

    /**
     * Set timing
     *
     * @param integer $timing
     *
     * @return ReqGroup
     */
    public function setTiming($timing)
    {
        $this->timing = $timing;

        return $this;
    }

    /**
     * Get timing
     *
     * @return integer
     */
    public function getTiming()
    {
        return $this->timing;
    }

    /**
     * Set user
     *
     * @param \Renshan\UserBundle\Entity\User $user
     *
     * @return ReqGroup
     */
    public function setUser(\Renshan\UserBundle\Entity\User $user = null)
    {
        $this->user = $user;

        return $this;
    }

    /**
     * Get user
     *
     * @return \Renshan\UserBundle\Entity\User
     */
    public function getUser()
    {
        return $this->user;
    }

    /**
     * Add target
     *
     * @param \Renshan\DetectorBundle\Entity\Target $target
     *
     * @return ReqGroup
     */
    public function addTarget(\Renshan\DetectorBundle\Entity\Target $target)
    {
        $this->targets[] = $target;

        return $this;
    }

    /**
     * Remove target
     *
     * @param \Renshan\DetectorBundle\Entity\Target $target
     */
    public function removeTarget(\Renshan\DetectorBundle\Entity\Target $target)
    {
        $this->targets->removeElement($target);
    }

    /**
     * Get targets
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getTargets()
    {
        return $this->targets;
    }

    /**
     * Add result
     *
     * @param \Renshan\DetectorBundle\Entity\Result $result
     *
     * @return ReqGroup
     */
    public function addResult(\Renshan\DetectorBundle\Entity\Result $result)
    {
        $this->results[] = $result;

        return $this;
    }

    /**
     * Remove result
     *
     * @param \Renshan\DetectorBundle\Entity\Result $result
     */
    public function removeResult(\Renshan\DetectorBundle\Entity\Result $result)
    {
        $this->results->removeElement($result);
    }

    /**
     * Get results
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getResults()
    {
        return $this->results;
    }
}
